package test.yzx.pproject.util;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;

public class CPUAnimView2 extends View {
    public CPUAnimView2(Context context) {
        super(context);
    }
    public CPUAnimView2(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    public CPUAnimView2(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }



    private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    private int strokeWidth = 4;
    private int drawPadding = strokeWidth;
    {
        paint.setStrokeWidth(strokeWidth);
        paint.setStrokeCap(Paint.Cap.ROUND);
    }
    private RectF rect;

    @Override
    protected void onDraw(Canvas canvas) {
        if(rect==null){
            rect = new RectF(drawPadding, drawPadding, getWidth()-drawPadding, getHeight()-drawPadding);
        }

        canvas.save();
        paint.setColor(Color.argb(100, 255, 255, 255));
        paint.setStyle(Paint.Style.STROKE);
        canvas.drawArc(rect, 0, 360, false, paint);
        canvas.restore();

        canvas.save();
        paint.setColor(Color.WHITE);
        paint.setStyle(Paint.Style.STROKE);
        canvas.drawArc(rect, -90, 90, false, paint);
        canvas.drawArc(rect, -90, -90, false, paint);
        canvas.restore();

    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, widthMeasureSpec);
    }


}
